package com.hz.mapper;

import com.hz.pojo.User;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

@Mapper
public interface UserMapper {

    @Insert("insert into user (username, password, create_time, update_time) VALUES " +
            "(#{username},#{password},now(),now())")
    void insert(String username, String password);

    @Select("select * from user where username = #{username}")
    User selectByName(String username);

    @Update("update user set username=#{username},nickname=#{nickname},email=#{email},update_time=#{updateTime} where id=#{id}")
    int update(User user);

    @Update("UPDATE user set user_pic=#{avatarUrl},update_time=now() where id=#{id}")
    int updateAvatar(String avatarUrl, Integer id);

    @Update("update user set password = #{newPwd},update_time=now() where username=#{username}")
    int updatePwd(String username, String newPwd);
}
